<%--
  Created by IntelliJ IDEA.
  User: kukudechao
  Date: 2018/8/13
  Time: 19:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="css/apply_approve.css" />
    <link rel="stylesheet" type="text/css" href="css/reset.css" />
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>

</head>
<body>
<div >


    <form action="${pageContext.request.contextPath}/AllagreeServlet.do" method="post" name="Allagree">
        <table class="dataintable">
            <tr>
                <td><input type="checkbox" name="allChecks"  onclick="allCheck(this.checked)">全选</td>
                <td>申请人学号</td>
                <td>申请人姓名</td>
                <td>现住宿舍楼号</td>
                <td>现住宿舍号</td>
                <td>想去宿舍楼号</td>
                <td>想去宿舍号</td>
                <td>申请时间</td>
                <td>申请原因</td>
                <td>操作</td>
            </tr>
            <c:forEach var="item" items="${sessionScope.apply}" >
                <tr>
                    <td >
                        <input type="checkbox" name="approveBox"  value="${item.go_build},${item.go_dor},${item.stu_id},${item.appro_id}" />
                    </td>
                    <td>${item.stu_no}</td>
                    <td>${item.stu_name}</td>
                    <td>${item.dor_build}</td>
                    <td>${item.dor_no}</td>
                    <td>${item.go_build}</td>
                    <td>${item.go_dor}</td>
                    <td>${item.apply_time}</td>
                    <td>${item.apply_rea}</td>
                    <td>
                        <button type="button" onclick="agree('${item.go_build}','${item.go_dor}','${item.stu_id}','${item.appro_id}')">批准</button>
                        <button type="button"  onclick="retur('${item.appro_id}')">驳回</button>
                    </td>
                </tr>
            </c:forEach>
        </table>
        <button type="button" onclick="allagree()">批量批准</button>
        <button type="button"onclick="Allrut()">批量驳回</button>
    </form>
    <div id="foot">

            <c:if test="${sessionScope.pageIndex==1}">
                首页
                上一页
            </c:if>
            <c:if test="${sessionScope.pageIndex>1}">
                <a href="${pageContext.request.contextPath}/MgrApproveServlet.do?pageIndex=1">首页</a>
                <a href="${pageContext.request.contextPath}/MgrApproveServlet.do?pageIndex=${sessionScope.pageIndex-1}">上一页</a>
            </c:if>
            <lib>${sessionScope.pageIndex}/${sessionScope.pageNum}</lib>
            <c:if test="${sessionScope.pageIndex<sessionScope.pageNum}">
                <a href="${pageContext.request.contextPath}/MgrApproveServlet.do?pageIndex=${sessionScope.pageIndex+1}">下一页</a>
                <a href="${pageContext.request.contextPath}/MgrApproveServlet.do?pageIndex=${sessionScope.pageNum}">尾页</a>
            </c:if>
            <c:if test="${sessionScope.pageIndex==sessionScope.pageNum}">
                下一页
                尾页
            </c:if>

    </div>



</div>
</body>

</html>
<script type="text/javascript">
<%--全选js--%>
    var ckeck=document.getElementsByName("approveBox");
    function allCheck(f){
        for (var i = 0; i < ckeck.length; i++) {
            ckeck[i].checked=f;
        }
    }
    //驳回
    function retur(n){
        location.href="${pageContext.request.contextPath}/ReturnApplyServlet.do?appro_id="+n;
    }
    //批准
    function agree(n,a,m,app) {
        location.href="${pageContext.request.contextPath}/UpdateStuDorServlet.do?go_build="+n+"&go_dor="+a+"&stu_id="+m+"&appro_id="+app;
    }
    function allagree() {
        var b=false;
        for(var i=0;i<ckeck.length;i++){
            if(ckeck[i].checked==true){
                b=true;
                break;
            }
        }

        if (b){
            var t=confirm("是否通过?!");
            if(t){
                document.Allagree.submit();
            }
        }
    }
    function Allrut() {
        var b=false;
        //选择了单选框
        for(var i=0;i<ckeck.length;i++){
            if(ckeck[i].checked==true){
                b=true;
                break;
            }
        }

        if (b){
            var t=confirm("是否驳回?!");
            if(t){
                document.Allagree.action="${pageContext.request.contextPath}/AllrutBatchStuServlet.do";
                document.Allagree.submit();
            }
        }
    }
</script>